import React, { Component } from 'react';
import TabControl from './TabControl'

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      titles: ["新款", "精选", "流行"],
      currentTitle: "新款",
    }
  }

  render() {
    const { titles, currentTitle } = this.state;

    return (
      <div>
        <TabControl itemClick={index => this.itemClick(index)} titles={titles}></TabControl>
        <h2>{currentTitle}</h2>
      </div>
    );
  }
  itemClick(index) {
    console.log(index);
    this.setState({
      currentTitle: this.state.titles[index],
    })


  }
}

export default App;